package com.infolab.aims.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.apache.commons.lang.StringUtils;
import org.hibernate.validator.constraints.NotBlank;

import com.infolab.aims.common.SpecialToStringStyle;
import com.infolab.aims.common.bean.AbstractModelBean;

@Entity
@Table(name = "AMTB_AUDIT")
public class Audit extends AbstractModelBean implements Serializable {

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long auditId;

	@NotBlank(message = "{error.empty}")
	private String moduleName;
	
	private String auditCode;

	@NotBlank(message = "{error.empty}")
	private String operation;

	@Column(length=1000)
	private String contentHead;
	
	@Column(length=2000)
	private String contentDetail;

	public String getModuleName() {
		return moduleName;
	}

	public void setModuleName(String moduleName) {
		this.moduleName = moduleName;
	}

	public String getOperation() {
		return operation;
	}

	public void setOperation(String operation) {
		this.operation = operation;
	}
	
	public String getContentHead() {
		return contentHead;
	}
	
	
	public String getContentHeadDesc() {
		if(StringUtils.isNotEmpty(contentHead)){
			String tmp = StringUtils.replace(contentHead, SpecialToStringStyle.SPECIAL_SEPARATE, ", ", -1);
			int size = tmp.length();
			if(size>=200)
				return tmp.substring(0, 200)+ "... ";
			else
				return tmp;
		}
		return "";
	}

	public void setContentHead(String contentHead) {
		this.contentHead = contentHead;
	}

	public String getContentDetail() {
		return contentDetail;
	}

	public void setContentDetail(String contentDetail) {
		this.contentDetail = contentDetail;
	}

	public Long getAuditId() {
		return auditId;
	}

	public void setAuditId(Long auditId) {
		this.auditId = auditId;
	}

	public String getAuditCode() {
		return auditCode;
	}

	public void setAuditCode(String auditCode) {
		this.auditCode = auditCode;
	}
}
